package com.example.beatbox;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

public class SoundViewModel extends BaseObservable {

    private Sound mSound;

    private BeatBox mBeatBox;

    public SoundViewModel(BeatBox beatBox){
        mBeatBox = beatBox;
    }

    public Sound getSound() {
        return mSound;
    }

    public void setSound(Sound mSound) {
        this.mSound = mSound;
        notifyChange();
    }

    @Bindable
    public String getTitle(){
        return mSound.getmName();
    }

    public void onButtonClicked() {
        mBeatBox.play(mSound);
    }

    public void setRate(Sound sound,float rate){
        mBeatBox.setRate(sound,rate);
    }
}
